package threadjuc;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author zxl
 * @version 1.0
 * @date 2021/10/27 19:26
 */
public class Juc9 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyThread myThread = new MyThread();
        //适配类
        FutureTask futureTask = new FutureTask(myThread);
        new Thread(futureTask,"A").start();
        //结果可能需要等待，回阻塞，所以一般放到最后
        Object o = futureTask.get();
        System.out.println(o);
    }
}
class MyThread implements Callable<String>{

    @Override
    public String call() throws Exception {
        System.out.println("哈哈");
        return "嘿嘿";
    }
}
